This step sometimes fails with an error such as: "A timestamp was
expected but was not found.". Any code-signing errors will result in
the notarisation step to fail.
Apparently this might be due to intermittent network issues. Let's just
retry codesigning a couple of times in the case it fails ...
See also: https://developer.apple.com/documentation/security/resolving-common-notarization-issues#Include-a-secure-timestamp
Signed-off-by: Jyrki Gadinger <nilsding@nilsding.org>
func codesign(identity: String, path: String, options: String = defaultCodesignOptions) throws {
print("Code-signing \(path)...")
let command = "codesign -s \"\(identity)\" \(options) \"\(path)\""
- guard shell(command) == 0 else {
- throw CodeSigningError.failedToCodeSign("Failed to code-sign \(path).")
+ for _ in 1...5 {
+ guard shell(command) == 0 else {
+ print("Code-signing failed, retrying ...")
+ continue
+ }
+
+ // code signing was successful
+ return
}
+
+ throw CodeSigningError.failedToCodeSign("Failed to code-sign \(path).")
}
func recursivelyCodesign(